VERSION 5.00
Begin VB.Form frmsubreport3 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Select month"
   ClientHeight    =   3750
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   6885
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   3750
   ScaleWidth      =   6885
   Begin VB.CommandButton Command1 
      Caption         =   "Run report"
      Height          =   495
      Left            =   4320
      TabIndex        =   2
      Top             =   1440
      Width           =   1095
   End
   Begin VB.CommandButton Command4 
      Caption         =   "EXPENDITURE BY OFFICE"
      Height          =   375
      Left            =   8520
      TabIndex        =   4
      Top             =   720
      Width           =   2655
   End
   Begin VB.CommandButton Command7 
      Caption         =   "EXPENDITURE FOR GINDO"
      Height          =   495
      Left            =   8280
      TabIndex        =   3
      Top             =   1080
      Width           =   2655
   End
   Begin VB.Frame Frame2 
      Height          =   3135
      Left            =   360
      TabIndex        =   5
      Top             =   240
      Width           =   6135
      Begin VB.ComboBox cboTY 
         Height          =   315
         Left            =   3840
         TabIndex        =   12
         Text            =   "2009"
         Top             =   720
         Width           =   1095
      End
      Begin VB.ComboBox cboFY 
         Height          =   315
         Left            =   3840
         TabIndex        =   11
         Text            =   "2009"
         Top             =   360
         Width           =   1095
      End
      Begin VB.ComboBox cboFinancial 
         Height          =   315
         Left            =   1200
         TabIndex        =   9
         Text            =   "ALL"
         Top             =   1200
         Width           =   2535
      End
      Begin VB.CommandButton Command2 
         Caption         =   "Close"
         Height          =   495
         Left            =   3960
         TabIndex        =   8
         Top             =   1800
         Width           =   1095
      End
      Begin VB.ComboBox cboFM 
         Height          =   315
         Left            =   1200
         TabIndex        =   0
         Text            =   "01"
         Top             =   360
         Width           =   1695
      End
      Begin VB.ComboBox cboTM 
         Height          =   315
         Left            =   1200
         TabIndex        =   1
         Text            =   "01"
         Top             =   720
         Width           =   1695
      End
      Begin VB.Label Label7 
         Alignment       =   1  'Right Justify
         Caption         =   "Year"
         Height          =   255
         Left            =   3360
         TabIndex        =   14
         Top             =   720
         Width           =   375
      End
      Begin VB.Label Label5 
         Alignment       =   1  'Right Justify
         Caption         =   "Year"
         Height          =   255
         Left            =   3120
         TabIndex        =   13
         Top             =   360
         Width           =   615
      End
      Begin VB.Label Label8 
         Alignment       =   1  'Right Justify
         Caption         =   "Financial"
         Height          =   255
         Left            =   240
         TabIndex        =   10
         Top             =   1200
         Width           =   855
      End
      Begin VB.Label Label4 
         Alignment       =   1  'Right Justify
         Caption         =   "From Month"
         Height          =   255
         Left            =   120
         TabIndex        =   7
         Top             =   360
         Width           =   975
      End
      Begin VB.Label Label6 
         Alignment       =   1  'Right Justify
         AutoSize        =   -1  'True
         Caption         =   "To Month"
         Height          =   195
         Left            =   360
         TabIndex        =   6
         Top             =   720
         Width           =   690
      End
   End
End
Attribute VB_Name = "frmsubreport3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False


Private Sub Command1_Click()
    Me.Hide
    isCreateNewExcel = True
    Call funExpenditureStatisticGindo(cboFinancial.Text, cboFM.Text, Right(cboFY.Text, 2), cboTM.Text, Right(cboTY.Text, 2))
    Unload Me
End Sub


Private Sub Command2_Click()
    Unload Me
End Sub

Private Sub cboFinancial_GotFocus()
    tem = SetFinancial(cboFM, Right(cboFY.Text, 2), cboTM.Text, Right(cboTY.Text, 2))
End Sub

Private Sub cboFM_Click()
    'tem = SetFinancial(cboFM, Right(cboFY.Text, 2), cboTM.Text, Right(cboTY.Text, 2))
End Sub

Private Sub cboFM_LostFocus()
    'tem = SetFinancial(cboFM, Right(cboFY.Text, 2), cboTM.Text, Right(cboTY.Text, 2))
End Sub

Private Sub cboFY_Click()
    'tem = SetFinancial(cboFM, Right(cboFY.Text, 2), cboTM.Text, Right(cboTY.Text, 2))
End Sub

Private Sub cboFY_LostFocus()
    'tem = SetFinancial(cboFM, Right(cboFY.Text, 2), cboTM.Text, Right(cboTY.Text, 2))
End Sub

Private Sub cboTM_Click()
    If Val(cboTY.Text) = Val(cboFY.Text) Then
        If Val(cboTM.Text) < Val(cboFM.Text) Then
            MsgBox "The TO MONTH must be greater then FROM MONTH", vbCritical + vbOKOnly, "Checking"
            Exit Sub
        End If
    End If
End Sub

 

Private Sub cboTM_LostFocus()
    'tem = SetFinancial(cboFM, Right(cboFY.Text, 2), cboTM.Text, Right(cboTY.Text, 2))
End Sub

Private Sub cboTY_Click()
    If Val(cboTY.Text) < Val(cboFY.Text) Then
        MsgBox "The TO YEAR must be greater then FROM YEAR", vbCritical + vbOKOnly, "Checking"
    End If
End Sub
Private Sub Form_Load()
    DetectExcel
    Me.Top = Screen.Height / 2 - (Me.Height / 1.5)
        Me.Left = Screen.Width / 2 - (Me.Width / 2)
    Call KetNoi
    
    
    
    
    DetectExcel
    Me.Top = Screen.Height / 2 - (Me.Height / 1.5)
        Me.Left = Screen.Width / 2 - (Me.Width / 2)
    Call KetNoi
    
    
    For i = 1 To 9
        cboFM.AddItem "0" & i
        cboTM.AddItem "0" & i
        If Val(i) = Month(Now()) Then
            cboFM.ListIndex = i - 1
            cboTM.ListIndex = i - 1
        End If
    Next
    
    For i = 10 To 12
        cboFM.AddItem i
        cboTM.AddItem i
    Next
    
    For i = 2008 To Year(Now()) + 1
        cboFY.AddItem i
        cboTY.AddItem i
    Next
    
    cboFY.Text = Year(Now())
    cboTY.Text = Year(Now())

      
End Sub
Private Function SetFinancial(fromMonth As Integer, fromYear As Integer, toMonth As Integer, toYear As Integer) As String
    Dim i As Integer
    cboFinancial.Clear
    If fromYear > toYear Then
        SetFinancial = "'From year' can not be greater then 'to year'"
        Exit Function
    ElseIf fromYear = toYear Then
        If fromMonth > toMonth Then
            SetFinancial = "'From month' can not be greater then 'to month'"
            Exit Function
        End If
    End If
    cboFinancial.AddItem "ALL"
    If fromMonth >= 1 And fromMonth <= 3 Then
        If fromYear - 1 < 10 Then
            cboFinancial.AddItem "0" & fromYear - 1 & "S"
        Else
            cboFinancial.AddItem fromYear - 1 & "S"
        End If
    End If
    For i = fromYear To toYear Step 1
        If i < 10 Then
            cboFinancial.AddItem "0" & i & "F"
            cboFinancial.AddItem "0" & i & "S"
        Else
            cboFinancial.AddItem i & "F"
            cboFinancial.AddItem i & "S"
        End If
        
    Next i
    cboFinancial.Text = "ALL"
    SetFinancial = ""
End Function
